#
# Driver makefile template
#

CFLAGS	:=
.PHONY: clean default
export EXTRA_CFLAGS	+= -I$(DRIVER_DIR)/inc/ -I$(HBINC_PATH) -I$(HBINC_PATH)/devlib/ -I$(HBINC_PATH)/base/

ifeq ($(DEBUG), y)
export EXTRA_CFLAGS	+= -DDRV_DEBUG
endif

ifeq ($(PLATFORM), HI3531)
export EXTRA_CFLAGS	+= -DPLATFORM_HI3531
endif

ifeq ($(PLATFORM), HI3531A)
export EXTRA_CFLAGS	+= -DPLATFORM_HI3531A
endif

ifeq ($(PLATFORM), HI3521)
export EXTRA_CFLAGS	+= -DPLATFORM_HI3521
endif

ifeq ($(PLATFORM), HI3521A)
export EXTRA_CFLAGS	+= -DPLATFORM_HI3521A
endif

ifeq ($(PLATFORM), HI3520A)
export EXTRA_CFLAGS	+= -DPLATFORM_HI3520A
endif

ifeq ($(PLATFORM), HI3520D)
export EXTRA_CFLAGS	+= -DPLATFORM_HI3520D
endif

ifeq ($(PLATFORM), HI3520D_V300)
export EXTRA_CFLAGS	+= -DPLATFORM_HI3520D_V300
endif

ifeq ($(PLATFORM), HI3516C)
export EXTRA_CFLAGS	+= -DPLATFORM_HI3516C
endif

ifeq ($(PLATFORM), HI3532)
export EXTRA_CFLAGS	+= -DPLATFORM_HI3532
endif

ifeq ($(PLATFORM), HI3520A_UCLIBC)
export EXTRA_CFLAGS	+= -DPLATFORM_HI3520A
endif

ifeq ($(PLATFORM), HI3521_UCLIBC)
export EXTRA_CFLAGS	+= -DPLATFORM_HI3521
endif

ifeq ($(PLATFORM), HI3535)
export EXTRA_CFLAGS	+= -DPLATFORM_HI3535
endif

ifeq ($(PLATFORM), HI3536)
export EXTRA_CFLAGS	+= -DPLATFORM_HI3536
endif

ifeq ($(SMALL_FLASH_SIZE), true)
EXTRA_CFLAGS		+= -DPLATFORM_UCLIBC
EXTRA_CFLAGS 		+= -DPLATFORM_SPI_NORFLASH_16M # 16M nor
else
ifeq ($(SINGLE_NOR_FLASH), true)
EXTRA_CFLAGS		+= -DPLATFORM_UCLIBC
EXTRA_CFLAGS 		+= -DPLATFORM_SPI_NORFLASH_16M # 16M nor
else
ifeq ($(SINGLE_NAND_FLASH), true)
EXTRA_CFLAGS		+= -DPLATFORM_GLIBC
EXTRA_CFLAGS 		+= -DPLATFORM_NANDFLASH_128M   # 128M nand
else
EXTRA_CFLAGS		+= -DPLATFORM_GLIBC
EXTRA_CFLAGS 		+= -DPLATFORM_SPI_NORFLASH_4M  # 4M nor + 256M nand
endif
endif
endif

$(warning EXTRA_CFLAGS = $(EXTRA_CFLAGS))
OUTPUT_KO := $(subst .o,.ko,$(obj-m))

OUTPUT_KO_DIR = $(OUTPUT_USR_LIB)
ifeq ($(BUILD_SLAVE_CHIP), true)
OUTPUT_KO_DIR = $(OUTPUT_ROOT_FS)/usr/lib/
endif

default:	
	$(MAKE) -C $(KERNEL_SRC_DIR) M=$(PWD) modules
	@$(MKDIR) -p $(OUTPUT_KO_DIR)
	$(CP) $(OUTPUT_KO) $(OUTPUT_KO_DIR)
	
clean:
	$(MAKE) -C $(KERNEL_SRC_DIR) M=$(PWD) clean
	$(RM) $(OUTPUT_KO_DIR)/$(OUTPUT_KO)

# vim:noet:sw=4:ts=4

